package com.onecar.carplatform.common.utils;

import io.netty.buffer.ByteBuf;

import java.nio.charset.Charset;

/**
 * @Author: ljq
 * @Description: ByteBuf 工具类
 * @Date: 2021/8/20 12:05
 * @Version: 1.0
 */

public class JtByteBufUtil {
    public static String buf2String(ByteBuf byteBuf, int len) {
        byte[] buf = new byte[len];
        byteBuf.readBytes(buf);
        return new String(buf);
    }

    public static String buf2StringGbk(ByteBuf byteBuf, int len) {
        byte[] buf = new byte[len];
        byteBuf.readBytes(buf);
        return new String(buf, Charset.forName("GBK"));
    }
}
